<%--
  Created by IntelliJ IDEA.
  User: xiangty 
  Date: 2018-04-17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增页面</title>
    <script type="text/javascript" src="../resources/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript">
        function yanzheng() {
            $.ajax({
                url: "${pageContext.request.contextPath}/infoAction?action=yanzheng",
                type: "post",
                data: {username: $("input[name=username]").val()},
                dataType: "json",
                success: function (result) {
                    var flag = result.flag;
                    var message = result.message;
                    $("#usernamemessage").html(message);

                    if (flag) {
                        //用户名称已经存在
                        $("#usernamemessage").css("color","red");
                    } else {
                        $("#usernamemessage").css("color","green");
                    }
                }
            });
        }

    </script>

</head>
<body>
    <form name="formname" action="${pageContext.request.contextPath}/infoAction">
        <input type="hidden" name="action" id="action" value="add" />
        名称:<input type="text" name="username" id="username" onblur="yanzheng();"/> <span id="usernamemessage"></span><br>
        密码:<input type="text" name="password" id="password"/> <br>
        <input type="submit" value="确认"/>
    </form>
</body>
</html>
